<template>
  <div>
    <div class="goods" @click="showDetail(goods.product_id)" draggable @dragstart="ondragstart($event, goods)">
      <div class="item_info">
        <h3>{{goods.product_name}}</h3>
        <h4>￥{{goods.out_price}}</h4>
      </div>
      <div class="imgbox imgtop">
        <img class="" style="width:100%;" alt="回归|90蛋糕" :src="goods.product_url1" />
      </div>
      <div class="imgbox imgbottom">
        <img class="" alt="回归|90蛋糕" :src="goods.product_url2" />
      </div>
    </div>

  </div>
</template>

<script>
export default {
  name: 'KodaiGoods',
  props: {
    goods: {
      type: Object,
      default: () => {
        return {};
      },
    }

  },
  data () {
    return {

    };
  },

  mounted () {

  },

  methods: {
    showDetail (id) {
      this.$router.push({
        path: '/MallProduct',
        //hash地址转向，用query对象传递参数
        query: {
          product_id: id
        }
      })
    },
    
    ondragstart (el, good) {
      this.$emit('ondragstart', el, good)
    }
  },
};
</script>


<style lang="scss" scoped>
.goods {
  display: block;
  position: relative;
  height: 280px;
  width: 280px;
  overflow: hidden;
  margin: 5px;
}

.goods:hover {
  box-shadow: 0px 0px 9px 0.1px rgba(0, 0, 0, 0.4);
}

.item_info {
  position: absolute;
  width: 250px;
  height: 50px;
  border: 1px solid #e7e7e7;
  left: 14px;
  bottom: 14px;
  background-color: rgba(255, 255, 255, .7);
  padding-top: 8px;
  z-index: 100;
}

.item_info h3 {
  margin: 0px;
  font-size: 10px;
  color: #3C2314;
  height: 22px;
  line-height: 22px;
  text-align: center;
  font-size: 100%;
  font-weight: 400;
}

.item_info h4 {
  font-size: 100%;
  font-weight: 400;
  color: #AA8764;
  height: 22px;
  line-height: 22px;
  text-align: center;
}

.imgbox {
  z-index: 10;
  position: absolute;
  top: 0;
  background-color: #fff;
  width: 280px;
  height: 280px;
  transition: all 0.8s ease-out;
  /*所有的属性在0.8秒之内完成改变*/

}

.imgtop {
  text-align: center;
  opacity: 1;
}

.imgbottom {
  opacity: 0;
  cursor: pointer;
  /*s鼠标移上去，变成一个小手的图标，这样比较美观*/
}

.imgbottom:hover {
  opacity: 1;
  transform: scale(1.6);
  /*这个是根据图片比例放大到图片的1.6倍*/
}
</style>